<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>Document</title>

    <style>
        body {
            margin: 0;
            padding: 0;
        }
        .container {
            width: 100vw;
            margin: 0 auto;
        }

        .header {
            height: 180px;
            background-image: url(img/banner.avif);
        }

        .pinned {
            display: flex;
            padding-top: 20px;
            padding-left: 400px;
        }

        .scroll {
            display: flex;
            padding-top: 20px;
            padding-left: 400px;
            padding-bottom: 50px;
            position: fixed;
            top: 0;
            left: 0;
            background-color: white;
            box-shadow: 0 0 10px black;
        }

        .header input {
            height: 40px;
            width: 400px;
            border-radius: 10px;
            border: 1px solid gray;
            opacity: 0.8;
        }

        .header button {
            /* height: 42px; */
            width: 42px;
            margin-left: 10px;
        }

        .banner img {
            width: 100vw;
        }

        .content img {
            width: 100vw;
        }
    </style>
</head>
<body>

    <div class="header">
        <div class="container pinned" id="search">
            <input type="text">
            <button>🔍</button>
        </div>
    </div>

    <div class="banner">
        <img src="img/b1.png" alt="banner">
    </div>

    <div class="content">
        <img src="img/c1.png" alt="c1">
        <img src="img/c1.png" alt="c1">
        <img src="img/c1.png" alt="c1">
    </div>

<script>
    let banner = document.querySelector(".banner")
    let bannerTop = banner.offsetTop
    let search = document.querySelector("#search")
    console.log(bannerTop)
    window.addEventListener("scroll", function() {
        if (document.documentElement.scrollTop >= bannerTop) {
            search.classList.add("scroll")
        } else {
            search.classList.remove("scroll")
        }
    })
</script>
</body>
</html>